# -*- coding: utf-8 -*-

import jieba

class JiebaCutWord(object):
    def __init__(self, user_dict=None) -> None:
        # 加载自定义词典
        if user_dict:
            jieba.load_userdict(user_dict)

    def segment(self,text):
        # 精确模式分词
        return list(jieba.cut(text, cut_all=False))
    
    def segment_with_pos(self, text):
        return [(word, flag) for word, flag in jieba.cut(text)]
